package gzx.datalayer.Data.Xingneng
{
	import mx.controls.Alert;
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;
	public class XingnengMgrQuery
	{
		private var remoteObject:RemoteObject
		
		public var onReceive_GetZhibiaoStatis:Function;
		public var onReceive_GetAlarmStatisInfo:Function;
		public var onReceive_GetCityAlarmStatisInfo:Function;
		public var onErrorFunction:Function;
		public function XingnengMgrQuery()
		{
			remoteObject  = new RemoteObject("fluorine");
			remoteObject.source = "RemoteFlunorineFx.XingNengMgr.StatisZhibiaoModul";
			
			remoteObject.GetZhibiaoStatis.addEventListener("result",GetZhibiaoStatis_ResultHandler);
			remoteObject.GetAlarmStatisInfo.addEventListener("result",GetAlarmStatisInfo_ResultHandler);
			remoteObject.GetCityAlarmStatisInfo.addEventListener("result",GetCityAlarmStatisInfo_ResultHandler);
			remoteObject.addEventListener("fault", onFault);
			
			onReceive_GetZhibiaoStatis = null;
			onReceive_GetAlarmStatisInfo = null;
			onReceive_GetCityAlarmStatisInfo = null;
			onErrorFunction = null;
		}
		//====================
		public function GetZhibiaoStatis(codition:XinNengStatisCodition,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.GetZhibiaoStatis(codition);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function GetZhibiaoStatis_ResultHandler(event:ResultEvent):void
		{
			if(null != onReceive_GetZhibiaoStatis)
				onReceive_GetZhibiaoStatis(event.result);
		}
		
		//====================
		public function GetAlarmStatisInfo(cityName:String,responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.GetAlarmStatisInfo(cityName);
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function GetAlarmStatisInfo_ResultHandler(event:ResultEvent):void
		{
			if(null != onReceive_GetAlarmStatisInfo)
				onReceive_GetAlarmStatisInfo(event.result);
		}
		
		//====================
		public function GetCityAlarmStatisInfo(responder:IResponder = null ):void
		{
			var asyncToken:AsyncToken = remoteObject.GetCityAlarmStatisInfo();
			
			if( responder != null )
				asyncToken.addResponder(responder);
		} 
		public function GetCityAlarmStatisInfo_ResultHandler(event:ResultEvent):void
		{
			if(null != onReceive_GetCityAlarmStatisInfo)
				onReceive_GetCityAlarmStatisInfo(event.result);
		}
		
		//=========================
		public function onFault (event:FaultEvent):void
		{
			if(onErrorFunction!=null)
			{
				onErrorFunction();
			}
			else
			{
				Alert.show(event.fault.faultString, "Error");
			}
		}
	}
}